package com.lin.fengxiu.model;

import com.lin.fengxiu.dto.SkuInfoDTO;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;

/**
 * @ClassName OrderSku
 * @Description TODO 订单写入DB的类
 * @Author wushaopei
 * @Date 2021/4/5 9:50
 * @Version 1.0
 */
@Setter
@Getter
@NoArgsConstructor
public class OrderSku {

    private Long id;
    /**
     * @Description TODO 当前 spu 对应sku的id
     */
    private Long spuId;
    /**
     * @Description TODO 当前sku单价 * 当前sku购买量
     */
    private BigDecimal finalPrice;
    /**
     * @Description TODO 当前sku的单价
     */
    private BigDecimal singlePrice;
    private List<String> specValues;
    private Integer count;
    private String img;
    private String title;

    public OrderSku( Sku sku ,SkuInfoDTO skuInfoDTO){
        this.id = sku.getId();
        this.spuId = sku.getSpuId();
        this.singlePrice = sku.getActualPrice();
        this.finalPrice = sku.getActualPrice().multiply(new BigDecimal(skuInfoDTO.getCount()));
        this.count = skuInfoDTO.getCount();
        this.img = sku.getImg();
        this.title = sku.getTitle();
        // 获取sku的当前规格值
        this.specValues = sku.getSpecValueList();
    }
}
